package server;

import java.io.IOException;
import java.io.Serializable;

import javax.sql.rowset.CachedRowSet;
import javax.sql.rowset.RowSetFactory;
import javax.sql.rowset.RowSetProvider;

public class CliMessage implements Serializable 
{
	private String messageFromServer;		// the message from server
	private CachedRowSet rowSet;			// the row set
	
	public CliMessage()
	{
		try
		{
			RowSetFactory rowSetFactory = RowSetProvider.newFactory();
			rowSet = rowSetFactory.createCachedRowSet();
		}
		catch(Exception x)
		{
			x.printStackTrace();
		}
	}
	public CliMessage(String messageFromServer)
	{
		this();
		this.messageFromServer = messageFromServer;
	}
	public CliMessage(String messageFromServer , CachedRowSet rowSet)
	{
		this(messageFromServer);
		this.rowSet = rowSet;	
	}

	 public String getMessageFromServer() {
		return messageFromServer;
	}
	private void writeObject(java.io.ObjectOutputStream out) throws IOException
	 {
		 out.writeObject(messageFromServer);
		 out.writeObject(rowSet);
	 }
	
	 @SuppressWarnings("unchecked")
	private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException
	 {
		 messageFromServer = (String) in.readObject();
		 rowSet = (CachedRowSet) in.readObject(); 
	 }
}
